package com.itheima.d1_char_stream;

import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;

/**
 * 目标：掌握文件字符输入流。
 */
public class FileReaderTest1 {
    public static void main(String[] args) {
        //extracted();
       // FileReader fr = new FileReader("字符串路径"/ File对象)
        try (FileReader file = new FileReader("day10io-app2/file/filwe01")) {
            int len;
            char[] buf = new char[1024];
            while ((len = file.read(buf)) != -1) {
                //把有效字符变成字符串
                String s = new String(buf, 0, len);
                System.out.println("s = " + s);
            }
        } catch (IOException e) {

            e.printStackTrace();
        }

    }

    private static void extracted() {
        try (FileReader file = new FileReader("day10io-app2/file/filwe01")) {
            int c;
            while ((c = file.read()) != -1) {
                System.out.println((char) c);
            }
        } catch (IOException e) {

            e.printStackTrace();
        }
    }
}
